package panda.li.navigation.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import panda.li.navigation.R;
import panda.li.navigation.activity.NewsActivity;
import panda.li.navigation.entity.BusLine;
import panda.li.navigation.entity.NewsInfo;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amap.api.services.busline.BusLineItem;

import panda.li.navigation.R;
import panda.li.navigation.entity.BusLine;

public class NewsAdapter extends BaseAdapter {


    private List<NewsInfo> newsInfoItems;
    private LayoutInflater layoutInflater;

    public NewsAdapter(Context context, List<NewsInfo> newsInfoItems) {
        this.newsInfoItems = newsInfoItems;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return newsInfoItems.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.item_news_list, null);
            holder = new ViewHolder();
            holder.title = (TextView) convertView.findViewById(R.id.title);
            holder.content = (TextView) convertView.findViewById(R.id.content);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.title.setText(newsInfoItems.get(position).getKind() +" :" + newsInfoItems.get(position).getTitle() );
        holder.content.setText("点击量:"
                + newsInfoItems.get(position).getClicks());
        return convertView;
    }

    class ViewHolder {
        public TextView title;
        public TextView content;
    }

}
